package com.future.lock.mall.view;

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.Gravity;
import android.view.View;
import android.widget.TextView;

import com.future.lock.R;
import com.yzh.modaldialog.dialog.impl.PopupDialog;
import com.yzh.modaldialog.dialog.impl.SelectorDialog;

/**
 * Created by yzh on 2017/12/28.
 */

public class PayMethodDialog extends PopupDialog {
    public int choice = 0;

    public PayMethodDialog(@NonNull Context context) {
        super(context, R.layout.dialog_pay_selector);
        setGravity(Gravity.CENTER);
    }

    @Override
    protected void onDialogCreate(Dialog dialog, Bundle savedInstanceState) {
        super.onDialogCreate(dialog, savedInstanceState);
        CheckableViewsRadioGroup viewsRadioGroup = dialog.findViewById(R.id.payMethodSelectRadioGroup);
        viewsRadioGroup.setOnCheckedChangeListener(new CheckableViewsRadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CheckableViewsRadioGroup group, int checkedId) {
                choice = checkedId == R.id.payViaAlipay ? 0 : 1;
            }
        });

        dialog.findViewById(R.id.cancel)
                .setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        choice = -1;
                        endModal(AlertDialog.BUTTON_NEGATIVE);
                    }
                });

        dialog.findViewById(R.id.confirmBtn)
                .setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        endModal(AlertDialog.BUTTON_POSITIVE);
                    }
                });
    }
}
